using System;
using System.Web.UI.WebControls;
using System.Text;
using OccurrencesWeb.WebUserControl;

namespace OccurrencesWeb.Page
{
    public abstract class ExtendedPageBase : System.Web.UI.Page
    {

        private WucMessage GetMessageUserControl()
        {
            return this.Master.FindControl("MessageUserControl") as WucMessage;
        }

        protected void ShowMessage(string strMessage, bool isErrorMessage)
        {
            WucMessage UserControl = GetMessageUserControl();
            if (UserControl != null)
                UserControl.ShowMessage(strMessage, isErrorMessage);
        }

        protected void ClearMessage()
        {
            WucMessage UserControl = GetMessageUserControl();
            if (UserControl != null)
                UserControl.ClearMessage();
        }

        public string PreviowsGridPageIndex
        {
            get
            {
                if (ViewState[WebConstants.KEY_GRID_PAGE_INDEX] != null)
                {
                    return ViewState[WebConstants.KEY_GRID_PAGE_INDEX].ToString();
                }

                return null;
            }
            set { ViewState[WebConstants.KEY_GRID_PAGE_INDEX] = value; }
        }

        /// <summary>
        /// Get the Empty option for dropdowns
        /// </summary>
        /// <returns>The List Item</returns>
        public DropDownList GetSelectOneMessageForFropDowns(DropDownList dropDown)
        {
            dropDown.Items.Add(new ListItem
            {
                Text = "Selecione",
                Value = string.Empty
            });
            return dropDown;
        }
    }
}
